<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            *{
                margin: 0px;
                padding: 0px;
                list-style: none;
            }
            textarea{
                width: 800px;
                resize: none;
                margin:50px auto;
                display: block;
                outline: none;
            }
            ul{
                width: 800px;
                margin:0px auto;
            }
            li{
                margin:20px 0px;
                border:1px solid red;
                position: relative;
                padding:20px;
            }
            .del{
                position: absolute;
                right:-10px;
                top:-10px;
                cursor: pointer;
            }
            button{
                width: 800px;
                background:saddlebrown;
                border:none;
                outline: none;
                display: block;
                margin:20px auto;
                line-height: 40px;
                color: white;
                cursor: pointer;
            }
        </style>
    </head>
    <body>
        <textarea name="" id="txt" cols="30" rows="10"></textarea>
        <button id="btn">发送</button>
        <ul id="box">
            <li>
                昨天停电了，xxxxx
                <p>2021-06-12</p>
                <span class="del" onclick="del(this)">S</span>
            </li>
            <li>
               今天端午节呢，xxxxx
                <p>2021-06-14</p>
                <span class="del" onclick="del(this)">S</span>
            </li>
        </ul>
        <script>
            // 获取标签
            var btn=document.getElementById('btn');
            var txt=document.getElementById('txt');
            var box=document.getElementById('box');
            // new Date()获取日期
            // 获取年份
            var year=new Date().getFullYear()
            // 获取月份 月份0-11月份
            var month=new Date().getMonth()+1
            // 获取日期
            var date=new Date().getDate()
            btn.onclick=function(){
                var val=txt.value;
                var tag=document.createElement('li');
                tag.innerHTML=`${val}
                <p>${year}-${month}-${date}</p>
                <span class="del" onclick="del(this)">X</span>`;
                // 追加标签
                box.appendChild(tag);
            }
            // 定义函数
            function del(a){
                a.parentNode.parentNode.removeChild(a.parentNode)
            }
        </script>
    </body>
</html>